//
//  OAYongZhanglistManagerVC.m
//  OA项目
//
//  Created by innofive on 2018/4/17.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAYongZhanglistManagerVC.h"
#import "MainTabBarViewController.h"
#import "MCSwitchTabControl.h"
#import "OAApprovelistCell.h"
#import "OAYongZhangDetailsVC.h"


@interface OAYongZhanglistVC()

@end
@implementation OAYongZhanglistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}


-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAYongZhangDetailsVC *vc = [[OAYongZhangDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"用章申请单";
    [self pushToVC:vc model:model];
    
}

@end

@interface OAYongZhanglist1VC()

@end

@implementation OAYongZhanglist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
@end


@interface OAYongZhanglist2VC()

@end

@implementation OAYongZhanglist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
@end


@interface OAYongZhanglist3VC()

@end

@implementation OAYongZhanglist3VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
@end

@interface OAYongZhanglistManagerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;
@end

@implementation OAYongZhanglistManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    OAYongZhanglistVC  *vc  = [[OAYongZhanglistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc.view.backgroundColor = [UIColor yellowColor];
    
    OAYongZhanglist1VC *vc1 = [[OAYongZhanglist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OAYongZhanglist2VC *vc2 = [[OAYongZhanglist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OAYongZhanglist3VC *vc3 = [[OAYongZhanglist3VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc2.view.backgroundColor = [UIColor brownColor];
    
    
    NSArray *vcs = @[vc,vc1,vc2,vc3];
    MainTabBarViewController *tabBarC = [MainTabBarViewController new];
    tabBarC.panGestureDelegate = self;
    tabBarC.tabBar.hidden = YES;
    tabBarC.viewControllers = vcs;
    [self addChildViewController:tabBarC];
    [self.view addV:tabBarC.view];
    _tabBarC = tabBarC;
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    MCSwitchTabControl *v = [MCSwitchTabControl new];
    [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
    [v insertSegmentWithTitle:@"待审核" image:nil];
    [v insertSegmentWithTitle:@"已通过" image:nil];
    [v insertSegmentWithTitle:@"已驳回" image:nil];
    [v insertSegmentWithTitle:@"转办" image:nil];
    [view addV:v];
    _tabControl = v;
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(0, 0, size.width,kFitH(45));
        weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
    }];
}

-(void)onClickChangeBtn:(MCSwitchTabControl *)button
{
    self.tabBarC.selectedIndex = button.selectedSegmentIndex;
    [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
}

-(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
{
    _tabControl.selectedSegmentIndex =selectedIndex;
    [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
